export default {
	namespaced: true,
	state: {
		Allcategory: [], //所有分类
		AllcategoryInfo: [] //所有分类详细信息
	},
	mutations: {
		setAllCategory(state, Allcategory) {
			state.Allcategory = [];
			state.Allcategory = Allcategory;
		},

		//vant item数据结构
		setallcategoryinfo(state, categoryinfo) {
			state.AllcategoryInfo = []
			state.Allcategory.forEach((item, i) => {
				var cate = {
					text: item.text
				}
				cate['children'] = []
				categoryinfo.forEach((item2, i2) => {
					if (item.text == item2.category) {
						let obj = {
							title: item2.title,
							img: item2.img
						};
						cate['children'].push(obj)
					}
				})
				state.AllcategoryInfo.push(cate)
			})

		}
	},
	actions: {
		setCategory(context, allcategory) {
			context.commit('setAllCategory', allcategory);
		},
		setCategoryInfo(context, allcategoryinfo) {
			context.commit('setallcategoryinfo', allcategoryinfo);
		}
	},
}
